<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>充值</title>
    <link rel="stylesheet" href="css/base.css" />
    <link rel="stylesheet" href="css/all.css" />
    <link rel="stylesheet" href="css/voucher.css" />
</head>
<body>
<div>
    <div class="heads">
       <span href="javascript:;" onclick="go()"><img src="img/zuojiantou.png" alt="" class="arrows"></span>
        <h1 class="titles">充值</h1>
    </div>
    <div class="middle">
        <div class="name">
            <img class="names" src="img/weixinzhifu.png" alt="">
            <span class="name-one">微信充值</span>
            <img class="duihao" src="img/duihao.png" alt="">
        </div>
        <div class="name-two">
            <img class="names" src="img/zhifubao.png" alt="">
            <span class="name-one">支付宝充值</span>
            <img class="duihao" src="img/duihao.png" alt="">
        </div>
        <div>
            <p class="sum">充值金额</p>
            <div>
                <span class="sums">￥</span>
                <input type="text" placeholder="" class="resetUpwd-input" />
            </div>
        </div>
    </div>
    <div type="button" class="submit" >
        <button class="submits">确定</button>
    </div>
</div>
<script src="js/all.js"></script>
<script src="js/jquery.js"></script>
<script src="js/secondLevel.js"></script>
<script src="js/x_rem.js"></script>
<script type="text/javascript">
	var recharge = 0;  //如果是0用微信，如果是1就用支付宝
	
	$(".name-two").children(".duihao").hide();   //支付宝充值的给隐藏了
	
	//点击支付宝充值
	$(".name-two").click(function(){
		$(".name-two").children(".duihao").show();  //支付宝的对勾给显示了
		$(".name").children(".duihao").hide();  //微信支付的对勾给隐藏了
		recharge = 1;  //改变为1
	})
	
	//点击微信充值
	$(".name").click(function(){
		$(".name-two").children(".duihao").hide();  //支付宝的对勾给隐藏了
		$(".name").children(".duihao").show();  //微信支付的对勾给显示了
		recharge = 0;
	})
	
	
	
	
	$(".submits").click(function(){
 
		if(!vali(".resetUpwd-input", /^\d{0,8}\.{0,1}(\d{1,2})?$/, "充值金额最多两位小数")){
			
		}else{
			if(recharge == 1){
				$.ajax({
					type:"post",
					url: Url+"/recharge/aLiRecharge",
					xhrFields:{
						withCredentials: true
					},
					data:{
						money:$(".resetUpwd-input").val()
					},
					success:((data)=>{
						console.log(data);
						if(data.success){
							localStorage.setItem('forms',JSON.stringify(data.message));//支付
							window.location.href="b.html";
						}else{
							popup(data.message);
						}
						
					}),
					error:((err)=>{
						console.log(err);
					})
				});
			}else{
				popup("暂时没有开通次功能");
			}
				
				
		}
		 
			
			
	})
	
	
	
	
	
	
	
	
	
	
</script>
</body>
</html>